﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace MobileControlGuru.AutoTask
{
    public partial class LogForm : MobileControlGuru.BaseForm
    {
        private static LogForm instance;
        public LogForm()
        {
            this.TopMost = true;
            InitializeComponent();


        }
        public static LogForm GetInstance()
        {
            if (instance == null || instance.IsDisposed)
            {
                instance = new LogForm();
            }
            return instance;
        }

        public void AppendLog(string message)
        {
            if (richTextBoxLog.InvokeRequired)
            {
                richTextBoxLog.Invoke(new Action<string>(AppendLog), message);
            }
            else
            {
                richTextBoxLog.AppendText(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + ": " + message + Environment.NewLine);
                richTextBoxLog.ScrollToCaret();
            }
        }
        private void LogForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (e.CloseReason == CloseReason.UserClosing)
            {
                e.Cancel = true;
                this.Hide();
            }
        }

        private void LogForm_Load(object sender, EventArgs e)
        {

        }
    }
}
